function C_prepareVideo(ID,Trigger)

global CG;

if nargin<2 Trigger = 'internal'; end
if nargin<1 ID = 1; end

switch architecture
 case 'MAC'; 
   Name = CG.Sessions.Video(ID).Name; 
   C_deleteVideo(ID); C_createVideo('Name',Name,'ID',ID); C_showVideo(ID,1); % OTHERWISE SR SCREWED UP
end

if ~isfield(CG,'Sessions') | ~isfield(CG.Sessions,'Video')
  C_createVideo;
end

if  strcmp(get(CG.Sessions.Video(ID).S,'Running'),'on')
  C_stopVideo(ID,0); % Stop without saving
end

% INITIALIZE PARAMETERS
CG.Sessions.Video(ID).Time = 0;
CG.Sessions.Video(ID).FramesAcquired = 0;
CG.Sessions.Video(ID).FramesThisIteration = 0;
CG.Sessions.Video(ID).TimeThisIteration = 0;
CG.Sessions.Video(ID).Iteration = 0;
if ~isfield(CG.Data,'Video')   CG.Data.Video(ID) = struct('Time',[],'RegionsToExclude',[]); 
else
  FN = fieldnames(CG.Data.Video); for iF=1:length(FN) CG.Data.Video(ID).(FN{iF}) = []; end
end

% UPDATE PARAMETERS
[Pars,PS] = C_getParametersModule('ModuleType','Video','IDType',ID);
CG.Sessions.Video(ID).SR = PS.SR; % SAMPLING RATE
CG.Sessions.Video(ID).ControlInterval = PS.ControlInterval;
ControlSamples = floor(PS.SR*PS.ControlInterval);
set(CG.Sessions.Video(ID).S,'FramesAcquiredFcnCount',ControlSamples);
CG.Sessions.Video(ID).BrightnessThreshold = PS.BrightnessThreshold;

%% CONFIGURE TRIGGER
C_setVideoOpts(ID,Trigger);

%% EMPTY THE RAM OF THE VIDEO
flushdata(CG.Sessions.Video(ID).S);

C_Logger('C_prepareVideo','Video starting...\n');
start(CG.Sessions.Video(ID).S);